package com.jagochan.imchat.module.common.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private TokenInterceptor tokenInterceptor;
    @Resource
    private ContextInfoCollectInterceptor contextInfoCollectInterceptor;

    /**
     * 先加入的拦截器先执行
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/capi/**");
        registry.addInterceptor(contextInfoCollectInterceptor).addPathPatterns("/capi/**");
    }
}
